package com.nut.lmsc.service.impl;

import com.nut.lmsc.common.Result;
import com.nut.lmsc.entity.GoodsSellMode;
import com.nut.lmsc.mapper.GoodsSellModeMapper;
import com.nut.lmsc.service.GoodsSellModeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

@Service
@Slf4j
public class GoodsSellModeServiceImpl implements GoodsSellModeService {

    @Autowired
    private GoodsSellModeMapper goodsSellModeMapper;

    @Override
    public Result<List<GoodsSellMode>> selectByGoodsId(Integer goodsId) {
        List<GoodsSellMode> list = goodsSellModeMapper.selectByGoodsId(goodsId);
        return Result.ok(list);
    }

    @Override
    public Result<GoodsSellMode> getById(Serializable id) {
        GoodsSellMode goodsSellMode = goodsSellModeMapper.selectById(id);
        return Result.ok(goodsSellMode);
    }

    @Override
    public Result add(GoodsSellMode goodsSellMode) {
        goodsSellModeMapper.insert(goodsSellMode);
        return Result.ok();
    }

    @Override
    public Result updateById(GoodsSellMode goodsSellMode) {
        goodsSellModeMapper.updateById(goodsSellMode);
        return Result.ok();
    }

    @Override
    public Result deleteByIds(Set<Integer> ids) {
        for (Integer id : ids) {
            goodsSellModeMapper.deleteById(id);
        }
        return Result.ok();
    }
}